package task;

/**
 * 接口实现类
 *
 * @Author Weton Li
 * @Date 2021/3/16 21:19
 */
public class ExtraBonusServiceImpl implements ExtraBonusService {

    private ExtraBonus extraBonus = new ExtraBonus();

    double rate11 = 0;
    double rate22 = 0;
    double rate33 = 0;

    double salary2 = 0;

    @Override
    public double getExtraBonus(int GMVinput) {

        if (GMVinput == 10000) {
            rate11 = extraBonus.rate1;
            salary2 = 10000*rate11;
        }

        if (GMVinput >= 10000 && GMVinput <= 100000) { // 12万 > 1万
            rate22 = extraBonus.rate2;
            salary2 = 10000*rate11+(GMVinput-10000)*rate22;
        }

        if (GMVinput > 10000){
            rate33 = extraBonus.rate3;
            salary2 = 10000*rate11+90000*rate22+(GMVinput-100000)*rate33; //10000 * 0.5% + 90000 * 1%  + 20000 * 2%。
        }

        return salary2;
    }
}
